﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebSite_that_use_Wizard.NET
{
    public partial class SourceFile : System.Web.UI.Page
    {
        private Wizard.IDataStoreContext mDataStoreContext;

        protected void Page_Load(object sender, EventArgs e)
        {
            var sessionDataStoreContext = (Wizard.Asp.AspEngine)Session["WizardEngine"];
            int querySourceFileId = int.Parse(Request.QueryString["id"]);
            mDataStoreContext = sessionDataStoreContext.DataStore.GetNewContext();

            var sourceFile = mDataStoreContext.GetSourceFile(querySourceFileId);
            HyperLink1.Text = "Application " + sourceFile.Application.ApplicationName;
            HyperLink1.NavigateUrl = "Application.aspx?id=" + sourceFile.Application.ApplicationId.ToString();
        }

        public class SourceFilePageHelper
        {

            public Wizard.Source.ISourceFile GetSourceFile(Wizard.IDataStoreContext sessionDataStoreContext, int querySourceFileId)
            {
                var result = sessionDataStoreContext.GetSourceFile(querySourceFileId);
                return result;
            }

            public void SaveSourceFile(
                Wizard.IDataStoreContext sessionDataStoreContext, 
                int querySourceFileId,
                string FileName, 
                string SourceText)
            {
                var result = sessionDataStoreContext.GetSourceFile(querySourceFileId);
                result.Update(sessionDataStoreContext, FileName, SourceText, false);
            }

        }

        protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
        {

        }

        protected void SourceFileDataSource_Updated(object sender, ObjectDataSourceStatusEventArgs e)
        {

        }

    }
}
